<html>
<head>
    
    <title>Ha.ckers.nl</title>
    
    <script type="text/javascript" src="js/jquery.js"></script>
            
    <script type="text/javascript">
    
    var ip = "<?php echo $_SERVER[ 'REMOTE_ADDR' ]; ?>";
    
    var tl = new Array(
    "<strong>Ha.ckers.nl</strong>",
    "login as:                                  root",
    "root@" + ip + "'s password:                      ***************",
    "Last login: Yesterday from " + ip,
    "[root@" + ip + " ~] ./start",
    "Welcome to Ha.ckers!",
    "At ha.ckers.nl you'll find tools we made, a blog, and more.",
    "For a list of commands type 'help'."
    );
    
    var speed = 25;
    var wait = 750;
    var queuecheck = 100;
    var rows = 22;
    
    var index = 0;
    var text_pos = 0;
    var str_length = tl[ 0 ].length;
    var contents, row;
    
    function type_text( )
    {
        
        contents = '';
        row = Math.max( 0, index - rows );
        while( row < index )
        {
            contents += tl[ row++ ] + '<br />';
        }
        
        var next = tl[ index ].substring( 0, text_pos );
        
        if( next.substring( ( next.length - 1 ) , next.length ) == '<' )
        {
            
            var sp = tl[ index ].substring( text_pos ).split( '>' );
            
            if( sp.length > 1 )
            {
                
                var tag = sp[0];
                var len = tag.length;
                
                text_pos = text_pos + len;
                
            }
            
        }
        
        document.getElementById('cont').innerHTML = contents + tl[ index ].substring( 0, text_pos ) + "<blink>_</blink>";
        
        if( text_pos++ == str_length )
        {
            
            text_pos=0;
            index++;
            if( index != tl.length )
            {
                
                str_length = tl[ index ].length;
                setTimeout( "type_text()", wait );
                
                document.getElementById( 'inp' ).disabled = true;
                
            }
            else
            {
                
                document.getElementById( 'inp' ).disabled = false;
                document.getElementById( 'inp' ).focus( );
                setTimeout( "check_type_text( )", queuecheck );
                            
            }
            
        } else {
            
            setTimeout( "type_text( )", speed );
            
        }
        
    }
    
    function doPress( event )
    {
        
        var inp = document.getElementById( 'inp' );
        
        if( event.keyCode && event.keyCode == 13 && inp.value != '' )
        {
            
            var command = inp.value;
            
            inp.value = '';
            
            inp.disabled = true;
            
            $.post( 'cmd.php', { cmd: command }, function(data)
            {
                
                var lines = data.split("\n");
                
                for( i = 0; i < lines.length; i++ )
                {
                    
                    tl[ tl.length ] = lines[ i ];
                                    
                }
                
            });
                    
        }
            
    }
    
    function check_type_text( )
    {
        
        if( index != tl.length )
        {
            
            str_length = tl[ index ].length;
            type_text( );
            document.getElementById( 'inp' ).disabled = true;
                        
        }
        else
        {
            
            setTimeout( "check_type_text( )", queuecheck );
                    
        }
            
    }
    </script>
    
    <style type="text/css">
    body {
        background: #000;
        color: #00FF00;
        font-family: Courier New;
        font-size: 12px;
    }
    
    #cont {
        height: 350px;
        border-bottom: 1px solid #ccc;
        overflow: hidden;
    }
    
    #inp {
        background: #000;
        border: 0;
        color: #00FF00;
        font-family: Courier New;
        font-size: 12px;
    }
    </style>
    
</head>

<body onload="type_text();">
    
    <div id="cont"></div>
    <label for="inp">[root@<?=$_SERVER[ 'REMOTE_ADDR' ]?> ~] </label><input type="text" id="inp" size="100" value="" autocomplete="off" onkeypress="doPress(event);" disabled="disabled" />
   
</body>
</html>